package com.beici.waterghost.controller;

import com.beici.waterghost.model.resultes;
import com.beici.waterghost.model.user;
import com.beici.waterghost.service.impl.fansServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/fans")
public class fansController {
    @Autowired
    private fansServiceImpl fansService;

    @PutMapping("/addfans/{userId}")
    public resultes addFans(@PathVariable("userId") Integer userId){
        user principal =
                (user) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
       return fansService.addFans(userId,principal.getUserId());
    }

    @GetMapping("/bznodes")
    public resultes getBZNodes(){
        user principal =
                (user) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
       return fansService.getBZNodes(principal.getUserId());
    }
}
